package cn.me.alphamq.broker.entity;

import cn.me.alphamq.broker.util.QueueIdUtil;

/**
 * 重试消费的消息
 *
 * @author f
 */
public class RetryConsumeMsg {

    /**
     * 消息的主题
     */
    private String topic;

    /**
     * 消费者组名
     */
    private String consumerGroup;

    /**
     * 写入重试消息的队列 id，默认随机生成
     */
    private int queueId;

    /**
     * 消息存放的偏移量
     */
    private int msgOffset;

    /**
     * 消息的长度
     */
    private int msgLength;

    /**
     * 当前重试次数
     */
    private int curRetryTimes;

    /**
     * 下次重试时间
     */
    private long nextRetryTime;

    public RetryConsumeMsg() {
    }

    public RetryConsumeMsg(String topic, String consumerGroup, int msgOffset, int msgLength, int curRetryTimes) {
        this.topic = topic;
        this.consumerGroup = consumerGroup;
        this.queueId = QueueIdUtil.genRandomQueueId(topic);
        this.msgOffset = msgOffset;
        this.msgLength = msgLength;
        this.curRetryTimes = curRetryTimes;
    }

    public String getTopic() {
        return topic;
    }

    public void setTopic(String topic) {
        this.topic = topic;
    }

    public String getConsumerGroup() {
        return consumerGroup;
    }

    public void setConsumerGroup(String consumerGroup) {
        this.consumerGroup = consumerGroup;
    }

    public int getQueueId() {
        return queueId;
    }

    public void setQueueId(int queueId) {
        this.queueId = queueId;
    }

    public int getMsgOffset() {
        return msgOffset;
    }

    public void setMsgOffset(int msgOffset) {
        this.msgOffset = msgOffset;
    }

    public int getMsgLength() {
        return msgLength;
    }

    public void setMsgLength(int msgLength) {
        this.msgLength = msgLength;
    }

    public int getCurRetryTimes() {
        return curRetryTimes;
    }

    public void setCurRetryTimes(int curRetryTimes) {
        this.curRetryTimes = curRetryTimes;
    }

    public long getNextRetryTime() {
        return nextRetryTime;
    }

    public void setNextRetryTime(long nextRetryTime) {
        this.nextRetryTime = nextRetryTime;
    }
}
